package com.mewpipe.dao;

import com.mewpipe.dao.CommentDao;
import com.mewpipe.dao.DaoFactory;
import com.mewpipe.dao.VideoDao;
import com.mewpipe.dao.UserDao;
import com.mewpipe.dao.jpa.JpaCommentDao;
import com.mewpipe.dao.jpa.JpaLnkCommentVideoDao;
import com.mewpipe.dao.jpa.JpaLnkUserLikeDao;
import com.mewpipe.dao.jpa.JpaLnkUserVideoDao;
import com.mewpipe.dao.jpa.JpaVideoDao;
import com.mewpipe.dao.jpa.JpaUserDao;
import com.mewpipe.entity.LnkUserVideo;
import com.mewpipe.util.PersistenceManager;

public class DaoFactory {
private static DaoFactory instance;
	
	private CommentDao commentDao;
	private VideoDao videoDao;
	private UserDao userDao;
	private LnkUserVideoDao lnkDao;
	private LnkUserLikeDao likeDao;
	private LnkCommentVideoDao lnkCVDao;
	
	public static DaoFactory getInstance() {
		if(instance == null) {
			instance = new DaoFactory();
		}
		return instance;
	}
	
	public CommentDao getCommentDao() {
		if(commentDao == null) {
			commentDao = new JpaCommentDao(PersistenceManager.getEntityManagerFactory());
		}
		return commentDao;
	}
	
	public VideoDao getVideoDao() {
		if(videoDao == null) {
			videoDao = new JpaVideoDao(PersistenceManager.getEntityManagerFactory());
		}
		return videoDao;
	}
	public UserDao getUserDao() {
		if(userDao == null) {
			userDao = new JpaUserDao(PersistenceManager.getEntityManagerFactory());
		}
		return userDao;
	}
	public LnkUserVideoDao getLnkDao() {
		if(lnkDao == null) {
			lnkDao = new JpaLnkUserVideoDao(PersistenceManager.getEntityManagerFactory());
		}
		return lnkDao;
	}
	public LnkUserLikeDao getLnkUserLikeDao() {
		if(likeDao == null) {
			likeDao = new JpaLnkUserLikeDao(PersistenceManager.getEntityManagerFactory());
		}
		return likeDao;
	}
	public LnkCommentVideoDao getLnkCommentVideoDao() {
		if(lnkCVDao == null) {
			lnkCVDao = new JpaLnkCommentVideoDao(PersistenceManager.getEntityManagerFactory());
		}
		return lnkCVDao;
	}
}
